home *** CD-ROM | disk | FTP | other *** search
/ Apple Color Graphics Sampler / Apple Color Graphics Sampler.iso / English / Screen Savers / Dark Side of the Mac / FaderShell / Blackout.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-25  |  5.0 KB  |  126 lines  |  [TEXT/MPS ]

  1. #ifndef __OSUTILS__
  2.     #include <OSUtils.h>
  3. #endif
  4. #include <QDOffscreen.h>
  5.  
  6. /* ------------------------------------------------------------------------------------    */
  7. /*    The following routines are used to help implement a blackout */
  8. /* ------------------------------------------------------------------------------------    */
  9.  
  10. // Returns a value from 0 to max-1
  11. short    Rnd(long max);
  12.  
  13. // Places a rectangle on one of the screens at random.  Rect is within screen bounds
  14. void PlaceRectOnScreen(
  15.     short width,            // width of rect, can be 0
  16.     short height,            // height of rect, can be 0
  17.     Rect * placedRect,        // Placed rect is returned here
  18.     Rect * margins,            // margins around screen, can be nil
  19.     Rect * screenBound);    // placed screen bounds returned here, can be nil
  20.     
  21. // Handy offscreen pixmap type routines
  22. void MyNewGWorld(GWorldPtr *offscreenGWorld,short PixelDepth,Rect *boundsRect,
  23.             CTabHandle cTable,GDHandle aGDevice,GWorldFlags flags);
  24. void MyDisposeGWorld (GWorldPtr offscreenGWorld);
  25. void MySetGWorld(GWorldPtr offscreenGWorld);
  26. void MyLockPixels(GWorldPtr offscreenGWorld);
  27. void MyUnlockPixels(GWorldPtr offscreenGWorld);
  28.  
  29. /* ------------------------------------------------------------------------------------    */
  30. /*    The following structure is used for setups                                            */
  31. /* ------------------------------------------------------------------------------------    */
  32. #define kSetupDialogID        10000
  33. #define kSettingsID            10000
  34. #define kSettingsType        'FSET'
  35.  
  36. typedef struct
  37.     {
  38.     ModalFilterProcPtr        okCancelFilterProc;
  39.     
  40.     ProcPtr        defaultUserItem;
  41.     ProcPtr        roundRectUser;
  42.     ProcPtr        aboutUserItem;
  43.     
  44.     ProcPtr        setUserItem;
  45.     ProcPtr        getItemCtlValue;
  46.     ProcPtr        setItemCtlValue;
  47.     ProcPtr        getClusterValue;
  48.     ProcPtr        setClusterValue;
  49.     ProcPtr        setLabeledCtlValue;
  50.     ProcPtr        setItemString;
  51.     ProcPtr        getItemString;
  52.     ProcPtr        getItemRect;
  53.     ProcPtr        centerWindow;
  54.     } SetupParamBlock;
  55.     
  56. #define OKCancelFilterProc    (*theSetup->okCancelFilterProc)
  57.     // standard filter proc for command-. and return/enter key
  58.     
  59. #define DefaultUserItem        (*theSetup->defaultUserItem)
  60.     // A user item for filling a useritem with a rounded rect for default buttons
  61. #define RoundRectUser        (*theSetup->roundRectUser)
  62.     // A user item for thin rounded rects
  63.  
  64. #define AboutUserItem        (*theSetup->aboutUserItem)
  65.     // A user item for drawing STR 10000 in 9 point applFont
  66.  
  67. #define SetUserItem            (*theSetup->setUserItem)
  68.     // For setting a given item's userItem proc : SetUserItem(dPtr, item, proc);
  69.     
  70. #define GetItemCtlValue        (*theSetup->getItemCtlValue)
  71.     // Returns an item's control value : value = GetItemCtlValue(dPtr, item);
  72.     
  73. #define SetItemCtlValue        (*theSetup->setItemCtlValue)
  74.     // Sets an item's control value : SetItemCtlValue(dPtr, item, value);
  75.     
  76. #define GetClusterValue        (*theSetup->getClusterValue)
  77.     // Gets a value for a cluster of controls, 0 = first control value = GetClusterValue(dPtr, min, max);
  78.     
  79. #define SetClusterValue        (*theSetup->setClusterValue)
  80.     // Sets the value for a cluster of controls, SetClusterValue(dPtr, min, max, value);
  81.     
  82. #define SetLabeledCtlValue    (*theSetup->setLabeledCtlValue)
  83.     // the value of a control, and a tag string on another item: SetLabeleCtlValue(dPtr, item, labelStaticItem, value);
  84.     
  85. #define SetItemString        (*theSetup->setItemString)
  86.     // Sets the string of an item, SetItemString(dPtr, item, string);
  87.     
  88. #define GetItemString        (*theSetup->getItemString)
  89.     // Gets the string of an item, GetItemString(dPtr, item, string);
  90.  
  91. #define GetItemRect        (*theSetup->getItemRect)
  92.     // gets the rectangle of, GetItemRect(dPtr, item, *theRect);
  93.  
  94. #define CenterWindow        (*theSetup->centerWindow)
  95.     // centers a WIND or DLOG template, CenterWindow(ResType theType, short resID, 
  96.     //    Point * wherePlaced) - wherePlaced may be nil
  97.  
  98.  
  99. /* ------------------------------------------------------------------------------------    */
  100. /*    The following routines are in the Blackout.  Change them to implement various displays.*/
  101. /* ------------------------------------------------------------------------------------    */
  102.  
  103. BlackoutHandle    PreflightBlackout(long * minSleepTime, long * maxSleepTime);
  104. Boolean            InitBlackout(BlackoutHandle theBlackout, WindowPtr blackoutWindow);
  105. void            BlackoutIdle(WindowPtr blackoutWindow, BlackoutHandle theBlackout);
  106. Boolean            BlackoutEvent(EventRecord *theEvent);
  107. void            DisposeBlackout(BlackoutHandle theBlackout);
  108.  
  109. /* ------------------------------------------------------------------------------------    */
  110. /*    Useful macros for your fader                                                         */
  111. /* ------------------------------------------------------------------------------------    */
  112. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  113. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  114. #define RectWidth(r) (short)((r)->right - (r)->left)
  115. #define RectHeight(r) (short)((r)->bottom - (r)->top)
  116.  
  117. /* ------------------------------------------------------------------------------------    */
  118. /*    The following globals are useful information about the Mac                             */
  119. /* ------------------------------------------------------------------------------------    */
  120. #ifndef INMAINBLACKOUT
  121.     extern SysEnvRec    theEnvirons;
  122. #endif
  123.  
  124. // Faders should be in the main segment by default
  125. #pragma segment Main
  126.